home *** CD-ROM | disk | FTP | other *** search
- @echo off
-
- goto endcomment
- REVISION HISTORY
- ----------------
-
- :endcomment
-
- BREAK ON
- cls
- echo ╔═════════════════════════════════════════════════════════════════════════════╗
- echo ║ ALARM ║
- echo ║ Function: Wait until a certain time, then sound an alarm. ║
- echo ║ Press CTL+BREAK to exit. ║
- echo ╚═════════════════════════════════════════════════════════════════════════════╝
-
- if not (%1)==() goto start
- rem color is white on blue
- echo ╔═════════════════════════════════════════════════════════════════════════════╗
- echo ║ USAGE : ALARM shows current time in hhmm format ║
- echo ║ USAGE : ALARM hhmm [msg] waits until hhmm, then sounds an alarm ║
- echo ║ ║
- echo ║ EXAMPLE : ALARM 0930 [sounds alarm at 9:30 am] ║
- echo ║ EXAMPLE : ALARM 930 Staff meeting [sounds alarm at 9:30 am] ║
- echo ║ EXAMPLE : ALARM 1800 [sounds alarm at 6:00 pm] ║
- echo ║ ║
- echo ║ For midnight, specify 0000 or 2400 for hhmm. ║
- echo ║ EXAMPLE : ALARM 2400 START MIDNIGHT BATCH RUN ║
- echo ║ ║
- echo ║ Note: Because this batch file does a LOT of disk activity, ║
- echo ║ it is STRONGLY recommended that you make your current ║
- echo ║ directory a RAM disk before running it. ║
- echo ║ ║
- echo ║ To prevent repeated disk accesses to find the FDATE program, ║
- echo ║ you should also have FDATE on the RAM disk, or be using a cache. ║
- echo ╚═════════════════════════════════════════════════════════════════════════════╝
- fdate /Ff /Ohh:mm:ss /P"Time is now: "
- goto endit
-
- :start
-
- rem If RAMDISK is specified, change to RAM disk. This will eliminate
- rem the tremendous amount of disk accesses this batch file does.
- rem ----------------------------------------------------------------
- IF NOT "%RAMDISK%"=="" %RAMDISK%:
-
- set alarm=%1
- shift
-
- rem get time now numeric representation
- fdate /Ff /Ohhmm /P"@set timenow=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- rem do a numeric compare: alarm time to 2400
- fdate /f#comp /A%alarm% /B2400 /P"@set comp=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- if (%comp%)==(ERROR) goto endit
-
- if (%comp%)==(LT) goto OKtime
-
- if (%comp%)==(EQ) set alarm=0000
- if (%comp%)==(EQ) goto OKtime
-
- echo ALARM REQUEST REJECTED. ALARM TIME [%alarm%] IS GREATER THAN 2400.
- goto endit
-
- :OKtime
-
- rem do a numeric compare: alarm time to timenow
- fdate /f#comp /A%alarm% /B%timenow% /P"@set comp=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- if (%comp%)==(EQ) echo ALARM REQUEST REJECTED. ALARM TIME [%alarm%] AND TIME NOW ARE THE SAME.
- if (%comp%)==(EQ) goto endit
-
- rem display time that alarm was set
- fdate /Ff
- fdate /Ff /Ohh:mm:ss /P"Alarm wait started at "
-
- if (%comp%)==(GT) goto latertoday
-
- rem else: fall through to tomorrow ...
-
- :tomorrow
-
- rem get the date that the alarm was set, i.e. today's date
- fdate /Ff /Omm-dd-ccyy /P"@set setdate=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- ECHO.
- ECHO WAITING UNTIL MIDNIGHT (TOMORROW, 0000 HOURS) BEFORE STARTING MAIN WAIT.
- ECHO.
- ECHO WAITING UNTIL: %alarm%
- ECHO MESSAGE:
- ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9
-
- rem loop until tomorrow
- :top1
- rem ---- WHILE condition ----------------------------------------
- rem compare today's date to setdate
- fdate /Fcomp /At /B%setdate% /P"@set comp=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- if (%comp%)==(GT) goto end1
-
- rem ---- loopbody -----------------------------------------------
- fdate /Ff /Ohh:mm:ss /P"Current time : "
- echo A
-
- goto top1
- :end1
-
- ECHO.
- ECHO MIDNIGHT ...
-
-
- rem -------------------------------------------------------------
- :latertoday
- ECHO.
- ECHO WAITING UNTIL: %alarm%
- ECHO MESSAGE:
- ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9
-
- :top2
- rem ---- WHILE condition ----------------------------------------
- rem get time now numeric representation
- fdate /Ff /Ohhmm /P"@set timenow=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- rem do a numeric compare: alarm time to timenow
- fdate /f#comp /A%timenow% /B%alarm% /P"@set comp=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- if (%comp%)==(GT) goto end2
- if (%comp%)==(EQ) goto end2
-
- rem ---- loopbody -----------------------------------------------
- fdate /Ff /Ohh:mm:ss /P"Current time : "
- echo A
-
- goto top2
- :end2
-
-
- rem -------------------------------------------------------------
- :alarm
-
- REM The time that was to be waited for has arrived.
- REM Sound alarm bell and display message.
-
- :top3
- cls
- BREAK OFF
- fdate /Ff /Ot1 /P"@set timenow=" >junktemp.bat
- call junktemp.bat
- del junktemp.bat
-
- rem color is white on red
- echo
-
- echo ╔══════════════════════════════════════════╗
- FOR %%V IN (x x x x x x x x) do echo ║ It is %timenow% Press ^BREAK to exit. ║
- echo ╚══════════════════════════════════════════╝
-
- BREAK ON
- FOR %%V IN (x x x x x x x x) do echo %1 %2 %3 %4 %5 %6 %7 %8 %9
-
- rem sound beeps. CONTROL-G is BEEP.
- echo
- GOTO top3
-
- :endit